Data Exchange in Embedded Systems – JSON vs Protocol Buffers

您所在的位置:网站首页 protobuf vs json Data Exchange in Embedded Systems – JSON vs Protocol Buffers

Data Exchange in Embedded Systems – JSON vs Protocol Buffers

#Data Exchange in Embedded Systems – JSON vs Protocol Buffers | 来源: 网络整理| 查看: 265

When we serialize the message from our example, it’s only 7 bytes long. This can be confusing at first because we would expect uint32 and float to be 8 bytes long when combined. However, Protocol Buffers won’t use all 4 bytes for uint32 if they can encode the data in fewer bytes. In this example, the sensor_id value can be stored in 1 byte. It means that in this serialized message, 1 byte is metadata for the first field, and the field data itself is only 1 byte long. The remaining 5 bytes are metadata and data for the second field; 1 byte for metadata and 4 bytes for data because float always uses 4 bytes in Protocol Buffers. This gives us 5 bytes or 71% of actual data in a 7-byte message.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3